package com.company.project.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.company.project.common.utils.DataResult;
import com.company.project.entity.TCallbakTaskEntity;
import com.company.project.service.TCallbakTaskService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;


/**
 * 
 *
 * @author wenbin
 * @email *****@mail.com
 * @date 2024-06-07 16:56:25
 */
@Controller
@RequestMapping("/")
public class TCallbakTaskController {
    @Resource
    private TCallbakTaskService tCallbakTaskService;


    /**
    * 跳转到页面
    */
    @GetMapping("/index/tCallbakTask")
    public String tCallbakTask() {
        return "tcallbaktask/list";
        }

    @ApiOperation(value = "新增")
    @PostMapping("tCallbakTask/add")
    @RequiresPermissions("tCallbakTask:add")
    @ResponseBody
    public DataResult add(@RequestBody TCallbakTaskEntity tCallbakTask){
        tCallbakTaskService.save(tCallbakTask);
        return DataResult.success();
    }

    @ApiOperation(value = "删除")
    @DeleteMapping("tCallbakTask/delete")
    @RequiresPermissions("tCallbakTask:delete")
    @ResponseBody
    public DataResult delete(@RequestBody @ApiParam(value = "id集合") List<String> ids){
        tCallbakTaskService.removeByIds(ids);
        return DataResult.success();
    }

    @ApiOperation(value = "更新")
    @PutMapping("tCallbakTask/update")
    @RequiresPermissions("tCallbakTask:update")
    @ResponseBody
    public DataResult update(@RequestBody TCallbakTaskEntity tCallbakTask){
        tCallbakTaskService.updateById(tCallbakTask);
        return DataResult.success();
    }

    @ApiOperation(value = "查询分页数据")
    @PostMapping("tCallbakTask/listByPage")
    @RequiresPermissions("tCallbakTask:list")
    @ResponseBody
    public DataResult findListByPage(@RequestBody TCallbakTaskEntity tCallbakTask){
        Page page = new Page(tCallbakTask.getPage(), tCallbakTask.getLimit());
        LambdaQueryWrapper<TCallbakTaskEntity> queryWrapper = Wrappers.lambdaQuery();
        //查询条件示例
        //queryWrapper.eq(TCallbakTaskEntity::getId, tCallbakTask.getId());
        IPage<TCallbakTaskEntity> iPage = tCallbakTaskService.page(page, queryWrapper);
        return DataResult.success(iPage);
    }

}
